package v1

import (
	"github.com/gin-gonic/gin"
	models "gin-ebook/Models"
	"gin-ebook/pkg/e"
	"gin-ebook/pkg/util"
	"log"
)

func AddDynamic(title string, desc string, createdBy string) (code int) {

	data := make(map[string]interface{})
	data["title"] = title
	data["desc"] = desc
	data["created_by"] = createdBy

	models.AddDynamic(data)
	code = e.SUCCESS
	return
}

func GetDynamic(c *gin.Context, maps map[string]interface{}) (code int, lists []models.Dynamic, total int64) {
	page, pageSize := util.GetPage(c)
	log.Println(page)
	log.Println(pageSize)
	lists = models.GetDynamic(page, pageSize, maps)
	total = models.GetDynamicTotal(maps)
	code = e.SUCCESS
	return
}
